﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Tenancy.Helper;
using System.Data;
using SQLServer.DBUtility;
using System.Text.RegularExpressions;
namespace Tenancy.Server
{
    /// <summary>
    /// Hbng_SearchTerm 的摘要说明
    /// </summary>
    public class Hbng_SearchTerm : IHttpHandler
    {
        /// <summary>
        /// 搜索条件，工程机械，高空作业平台。包括平台，型号，停放地的下拉内容
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
           

            string Hb_PBrands = string.Format("select DISTINCT brand  from View_DeviceDetail where brand is not null ");//品牌
            DataTable PBrandsData = DbLocalSQL.Query(Hb_PBrands).Tables[0];
            string Hb_PlatformHeight = string.Format("select DISTINCT PlatformHeight  from View_DeviceDetail where PlatformHeight is not null ");//平台高度
            DataTable PlatformHeightData = DbLocalSQL.Query(Hb_PlatformHeight).Tables[0];
            string Hb_modelCode = string.Format("select DISTINCT modelCode  from View_DeviceDetail where modelCode is not null ");//机器型号 
            DataTable modelCodeData = DbLocalSQL.Query(Hb_modelCode).Tables[0];
            string Hb_DriveWay = string.Format("select DISTINCT DriveWay  from View_DeviceDetail where DriveWay is not null ");//驱动方式
            DataTable DriveWayData = DbLocalSQL.Query(Hb_DriveWay).Tables[0];
            string Hb_ParkAddressCurProvince = string.Format("select DISTINCT ParkAddressCurProvince  from View_DeviceDetail  where ParkAddressCurProvince is not null ");//停放地
            DataTable ParkAddressCurProvinceData = DbLocalSQL.Query(Hb_ParkAddressCurProvince).Tables[0];
            Dictionary<string, object> tab = new Dictionary<string, object>();
            tab.Add("pinpai", JsonHelper.DataTableToList(PBrandsData));
            tab.Add("pingtai", JsonHelper.DataTableToList(PlatformHeightData));
            tab.Add("xinghao", JsonHelper.DataTableToList(modelCodeData));
            tab.Add("qudong", JsonHelper.DataTableToList(DriveWayData));
            tab.Add("tingfang", JsonHelper.DataTableToList(ParkAddressCurProvinceData));

            Dictionary<string, object> msg = new Dictionary<string, object>();
            msg.Add("code","0");
            msg.Add("msg", "success");
            msg.Add("data", tab);
            string tmp = JsonHelper.ObjectToJSON(msg);
            context.Response.Write(tmp);

        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}